﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VoucherInReturnList.aspx.cs"
    Inherits="SalesManagement.Modules.Sales.VoucherInReturnList" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Dách phiếu nhập mua hàng</title>

    <script language="javascript" type="text/javascript">
        function DocumentReady() {
            var obj = document.getElementById('ResourceManager1');
            MethodNamespace.DocumentReady({
                success: function() {
                storeVoucherList.reload();
                }
            });
        }
        /*
        Khi chọn Phiếu Nhập kho load chi tiết phiếu nhập
        */
        function SelectionChange(Selection) {
            if (Selection.selections.items.length > 0) {
                var Row = Selection.selections.items[0];
                MethodNamespace.SelectionChange(Row.data.VoucherId);
            }
        }

        function SearchDocument() {
            MethodNamespace.SearchDocument(1, {
                success: function() {
                    Complete_Search(grVoucherList, null, null, txtVoucherNo);
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="MethodNamespace">
        <Listeners>
            <DocumentReady Handler="DocumentReady();" Delay="100" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Store ID="storeObject" runat="server" RemoteSort="true">
        <Reader>
            <ext:JsonReader IDProperty="ObjectId">
                <Fields>
                    <ext:RecordField Name="ObjectId" />
                    <ext:RecordField Name="ObjectName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeWarehouse" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="WarehouseId">
                <Fields>
                    <ext:RecordField Name="WarehouseId" />
                    <ext:RecordField Name="WarehouseName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeEmployee" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="EmployeeId">
                <Fields>
                    <ext:RecordField Name="EmployeeId" />
                    <ext:RecordField Name="EmployeeName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="RowLayout">
        <Items>
            <ext:Toolbar ID="tbMain" runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNew" Icon="PageAdd" Text="Tạo mới">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip9" runat="server" Title="Ctr+N">
                            </ext:ToolTip>
                        </ToolTips>
                        <%--    <Listeners>
                                    <Click Handler="BeforCheckNewClick();" />
                                </Listeners>--%>
                    </ext:Button>
                    <ext:ToolbarSeparator />
                    <ext:Button runat="server" ID="btnUpdate" Text="Sửa" Icon="PageEdit">
                    </ext:Button>
                    <ext:ToolbarSeparator />
                    <ext:Button runat="server" ID="btnDelete" Text="Xóa" Icon="Delete">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip8" runat="server" Title="Shift+Delete">
                            </ext:ToolTip>
                        </ToolTips>
                        <%--    <Listeners>
                                    <Click Handler="ConfigDeleteObject()" />
                                </Listeners>--%>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
            <ext:FormPanel ID="FormWindow" runat="server" Split="true" Frame="false" Header="false"
                Border="false" Layout="FormLayout">
                <Items>
                    <ext:Panel ID="Panel0" runat="server" Frame="true" Height="100" Layout="ColumnLayout"
                        Padding="5" BodyStyle="background-color:transparent;" BodyBorder="false">
                        <Defaults>
                            <ext:Parameter Name="Anchor" Value="99%">
                            </ext:Parameter>
                        </Defaults>
                        <Items>
                            <ext:Panel ID="Panel1" runat="server" ColumnWidth="0.5" Layout="FormLayout" LabelWidth="100"
                                BodyStyle="background-color:transparent;" BodyBorder="false">
                                <Defaults>
                                    <ext:Parameter Name="Anchor" Value="99%">
                                    </ext:Parameter>
                                </Defaults>
                                <Items>
                                    <ext:TextField runat="server" ID="txtVoucherNo" FieldLabel="Số phiếu" />
                                    <ext:DateField ID="dfDateFrom" runat="server" FieldLabel="Từ ngày" />
                                    <ext:ComboBox ID="cboWarehouse" runat="server" FieldLabel="Tên kho" Editable="false"
                                        StoreID="storeWarehouse" DisplayField="WarehouseName" ValueField="WarehouseId" />
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="Panel2" runat="server" ColumnWidth="0.4" Layout="FormLayout" LabelWidth="70"
                                BodyStyle="background-color:transparent;" BodyBorder="false">
                                <Defaults>
                                    <ext:Parameter Name="Anchor" Value="99%">
                                    </ext:Parameter>
                                </Defaults>
                                <Items>
                                    <ext:ComboBox ID="cboObject" runat="server" FieldLabel="Khách hàng" Editable="false"
                                        StoreID="storeObject" DisplayField="ObjectName" ValueField="ObjectId" />
                                    <ext:DateField ID="dfDateTo" runat="server" FieldLabel="Đến ngày" />
                                    <ext:ComboBox ID="cboEmployee" runat="server" FieldLabel="Nhân viên" Editable="false"
                                        StoreID="storeEmployee" DisplayField="EmployeeName" ValueField="EmployeeId" />
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="pnlPackCenter" runat="server" Layout="VBoxLayout" ColumnWidth="0.1"
                                BodyStyle="background-color:transparent;" BodyBorder="false">
                                <Defaults>
                                    <ext:Parameter Name="margins" Value="0 0 5 0" Mode="Value" />
                                </Defaults>
                                <LayoutConfig>
                                    <ext:VBoxLayoutConfig Padding="5" Align="Center" Pack="Center" />
                                </LayoutConfig>
                                <Items>
                                    <ext:Button ID="btSearch" runat="server" Text="Tìm kiếm" Icon="Magnifier" FormBind="true"
                                        Width="60" Height="30">
                                        <Listeners>
                                            <Click Handler="SearchDocument()" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:FormPanel>
            <ext:GridPanel ID="grVoucherList" runat="server" AutoExpandColumn="objCustomer" RowHeight="1"
                AutoWidth="True" Border="false">
                <Store>
                    <ext:Store ID="storeVoucherList" runat="server" OnRefreshData="VoucherList_OnRefreshData">
                        <Reader>
                            <ext:JsonReader IDProperty="VoucherId">
                                <Fields>
                                    <ext:RecordField Name="VoucherId" />
                                    <ext:RecordField Name="VoucherNo" />
                                    <ext:RecordField Name="VocherDate" />
                                    <ext:RecordField Name="ObjectName" />
                                    <ext:RecordField Name="WarehouseName" />
                                    <ext:RecordField Name="EmployeeName" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <BaseParams>
                            <ext:Parameter Name="start" Value="0" Mode="Raw" />
                            <ext:Parameter Name="limit" Value="50" Mode="Raw" />
                        </BaseParams>
                         <Listeners>
                            <Load Handler=" Complete_Search(grVoucherList, null, null, txtVoucherNo);" Delay="10" />
                        </Listeners>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="VoucherNo" DataIndex="VoucherNo" Header="Số phiếu" />
                        <ext:Column DataIndex="VocherDate" Header="Ngày tạo" />
                        <ext:Column DataIndex="ObjectName" Header="Khách hàng" />
                        <ext:Column DataIndex="WarehouseName" Header="Tên kho" />
                        <ext:Column DataIndex="EmployeeName" Header="Nhân viên phụ trách" />
                    </Columns>
                </ColumnModel>
                 <SelectionModel>
                    <ext:RowSelectionModel SingleSelect="true">
                        <Listeners>
                            <SelectionChange Fn="SelectionChange" />
                        </Listeners>
                    </ext:RowSelectionModel>
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar ID="pdgrnMain" runat="server" PageSize="10">
                    </ext:PagingToolbar>
                </BottomBar>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
            <ext:GridPanel ID="GridPanel2" runat="server" AutoExpandColumn="ProductName" Height="170"
                Border="false">
                <Store>
                    <ext:Store ID="storeMain" runat="server" RemoteSort="true">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <Reader>
                            <ext:JsonReader IDProperty="VoucherInId">
                                <Fields>
                                    <ext:RecordField Name="VoucherInId" />
                                    <ext:RecordField Name="VoucherInNo" />
                                    <ext:RecordField Name="VocherInDate" />
                                    <ext:RecordField Name="BranchId" />
                                    <ext:RecordField Name="ProviderId" />
                                    <ext:RecordField Name="ContractId" />
                                    <ext:RecordField Name="PaymentMethodId" />
                                    <ext:RecordField Name="MaturityId" />
                                    <ext:RecordField Name="PaymentStatus" />
                                    <ext:RecordField Name="Status" />
                                    <ext:RecordField Name="Note" />
                                    <ext:RecordField Name="Deleted" />
                                    <ext:RecordField Name="CreatedDate" />
                                    <ext:RecordField Name="CreatedBy" />
                                    <ext:RecordField Name="UpdatedDate" />
                                    <ext:RecordField Name="UpdatedBy" />
                                    <ext:RecordField Name="CurrencyId" />
                                    <ext:RecordField Name="CurrencyRate" />
                                    <ext:RecordField Name="InputMethodId" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel2" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="ProductCode" DataIndex="ProductCode" Header="Mã hàng" />
                        <ext:Column ColumnID="ProductName" DataIndex="ProductName" Header="Tên hàng" />
                        <ext:Column ColumnID="CategoryName" DataIndex="CategoryName" Header="Nhóm hàng" />
                        <ext:Column ColumnID="StockPrice" DataIndex="StockPrice" Header="StockPrice" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                </BottomBar>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
